﻿using System;
using System.Collections.Generic;
using Tesla.Service.DataContracts;
using System.Linq;
using System.Text;
using Tesla.Util.Utilities;

namespace Tesla.Business.BusinessLogic.Implementations
{
    public abstract class BaseOperationalBL
    {
        public virtual int? Create(BaseDC contractObject)
        {
            throw new NotImplementedException("Create Not Implemented");
        }

        public virtual int Update(BaseDC contractObject)
        {
            throw new NotImplementedException("Update Not Implemented");
        }

        public virtual IList<BaseDC> DisplayAll(int gridSize, ref int? totalRecordCount)
        {
            throw new NotImplementedException("Read Not Implemented");
        }

        public virtual IList<BaseDC> SearchByName(string name, int gridSize, ref int? totalRecordCount)
        {
            throw new NotImplementedException("Search By Name Not Implemented");
        }

        public virtual IList<BaseDC> Read(int id)
        {
            throw new NotImplementedException("Read Not Implemented");
        }

        public virtual IList<BaseDC> ReadByRange(int startRecordNo, int endRecordNo, string sortColName, string sortDirection, string searchString)
        {
            throw new NotImplementedException("Read By Range Not Implemented");
        }
        //METHOD TO READ ALL DATA POSSIBLY TO SHOW IN A LISTBOX
        public virtual IList<BaseDC> ReadAll()
        {
            throw new NotImplementedException("Read All Not Implemented");
        }
    }

    public static class BLFactory
    {
        public static BaseOperationalBL CreateInstance(int id)
        {
            BaseOperationalBL instance = GenericClassFactory<int, BaseOperationalBL>.CreateInstance(id);
            if (instance == null)
            {
                string typeName = ResolveMapper.ResolveMethod(id);
                Type type = Type.GetType(typeName);
                GenericClassFactory<int, BaseOperationalBL>.Add(id, type);
                instance = GenericClassFactory<int, BaseOperationalBL>.CreateInstance(id);
            }
            return instance;
        }
    }
}
